package com.vast.ui.component.socketinterface.server.newio;

import java.nio.channels.SocketChannel;

import com.vast.ui.component.socketinterface.request.Request;
import com.vast.ui.component.socketinterface.request.RequestQueue;
import com.vast.ui.component.state.Sequence;
import com.vast.ui.component.util.ConsoleLoggerSingleton;
import com.vast.ui.component.util.Logger;

public class SendHandler  implements Runnable {
    private SocketChannel       socketChannel;
	private final Sequence      sequence;
	private final RequestQueue  sendQueue;
	private final Logger        logger;
	
	SendHandler(SocketChannel socketChannel, Sequence sequence, RequestQueue sendQueue) {
        this.socketChannel = socketChannel;
        this.sequence      = sequence;
        this.sendQueue     = sendQueue;
        this.logger        = ConsoleLoggerSingleton.getInstance();
    }
    
    public void run() {
        try {           
            while(sequence.isSendConnection()) {
            //	Request request = sendQueue.getRequest();
            	
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
            	sequence.closeReceiveConnection();
                socketChannel.close();
            } catch (Exception e) {}
        }
    }
}
